package com.briup.test;

import com.briup.Dao.StuMapper;
import com.briup.pojo.Student;
import com.briup.uitls.SqlSessionFactoryUtils;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;



//插入一条学生信息
public class Insert {
  public static void main(String[] args) {
      SqlSession sqlSession = null;
      Student student = new Student(null, "abcd", "男", "3");
      try  {
          SqlSessionFactory sqlSessionFactory = SqlSessionFactoryUtils.getSqlSessionFactory();
          sqlSession = sqlSessionFactory.openSession(true);
          StuMapper mapper = sqlSession.getMapper(StuMapper.class);
          int insert = mapper.insert(student);
          System.out.println(student.getId());
          System.out.println(insert);
      }catch (Exception e){
          e.printStackTrace();
      }finally{
          sqlSession.close();
      }
  }
}
